package stage.manager;

import java.util.logging.Level;
import java.util.logging.Logger;

import stage.pojo.*;
/**
 * convert new come info to historical info, used by add action. 
 * @author remi liu(Liu Zhibin)
 * @version 0.5
 */
public class ConvertInfo {
	public static HistoricalInfo toHistoricalInfo(NewcomeInfo newcomeInfo){
		Character h;
		if(newcomeInfo.getHospital().equals("宝安区人民医院"))
			h='a';
		else if(newcomeInfo.getHospital().equals("宝安区沙井人民医院"))
			h='b';
		else 
			h='c';
		Character d=(newcomeInfo.getDepartment().equals("妇科")?'a':'b');
		Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.INFO, newcomeInfo.getIsExpert());
		Boolean i=((newcomeInfo.getIsExpert().equals("专家号")||newcomeInfo.getIsExpert().equals("true"))?true:false);
		Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.INFO, i.toString());
		Integer w=null;
		if(newcomeInfo.getWeather().equals("晴")||newcomeInfo.getWeather().equals("多云"))
			w=1;
		else if(newcomeInfo.getWeather().equals("阴"))
			w=2;
		else if(newcomeInfo.getWeather().equals("小到中雨")||newcomeInfo.getWeather().equals("小到中雪")||newcomeInfo.getWeather().equals("雾"))
			w=3;
		else if(newcomeInfo.getWeather().equals("雷阵雨")||newcomeInfo.getWeather().equals("冰雹"))
			w=4;
		else if(newcomeInfo.getWeather().equals("大到暴雨")||newcomeInfo.getWeather().equals("大雪"))
			w=5;
		else w=0;
		
		return (new HistoricalInfo(h,d,i,newcomeInfo.getWeekOrdinal(),newcomeInfo.getWeekday(),w,newcomeInfo.getNum()));
	}
}
